package com.example.basicquestions.questions.木板;

import java.util.*;

/**
 * @author liw
 * @date 2023-03-10
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] nums = new int[n];
        for (int i = 0; i < nums.length;i++){
            nums[i] = scanner.nextInt();
        }
        Arrays.sort(nums);
        while (m>0){
            for(int i = 1; i <n; i++){
                if(nums[i] > nums[i-1]){
                    nums[i-1]++;
                    break;
                }

                if(n==i){
                    nums[n]++;
                }
            }
            m--;
        }

        System.out.println(nums[0]);
    }
}
